//
//  ViewModel.swift
//  SSNetworking_Example
//
//  Created by 松松 on 2019/4/10.
//  Copyright © 2019年 CocoaPods. All rights reserved.
//

import UIKit
@_exported
import RxSwift
import RxCocoa
import Moya
import Alamofire
import SSNetworking


class ViewModel: NSObject {

    var bag : DisposeBag = DisposeBag()

    let providerLoding = MoyaProvider<ApiManager>(endpointClosure: endpointMapping,manager: defaultAlamoFireManager(), plugins: [RequestLoadingPlugin(),netWorkActivityPlugin])

    let noTostProvider = MoyaProvider<ApiManager>(endpointClosure: endpointMapping,manager: defaultAlamoFireManager(), plugins: [NoToastRequestPlugin(),netWorkActivityPlugin])

    func getData(){
        providerLoding.rx.request(.GetNoParameter(url: "api/v1/wfVehicleModels"))
            .filterSuccessfulStatusCodes()
            .mapObject(MessageModel.self)
            .subscribe(onSuccess: { (model) in
                ssPrint(model)
            }, onError: { (err) in
                ssPrint(err)
            }).disposed(by: bag)
    }

}
